﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml;
using System.Xml.Linq;
using Business_Object;
using Models;

namespace BusinessService
{
    public partial class TestSave : System.Web.UI.Page
    {
        private DiaDiemService diaDiemService = new DiaDiemService(); 
        protected void Page_Load(object sender, EventArgs e)
        {
            //String filePath = HttpContext.Current.Server.MapPath("~/MyPlace/DiaDiem.xml");
           
            //DiaDiemService diemService = new DiaDiemService();
            //XmlParser xmlParser = new XmlParser();
            //XmlDocument doc = xmlParser.ConvertObjectToXml(diemService.All());
            //doc.Save(filePath);
            //if (Session["username"] != null)
            //{
                String name = Request["name"];
                String address = Request["address"];
                String description = Request["description"];
                int type = int.Parse(Request["type"]);
                double lat = double.Parse(Request["lat"]);
                double lng = double.Parse(Request["lng"]);


                DiaDiem diaDiem = new DiaDiem();
                diaDiem.TenDiaDiem = name;
                diaDiem.DiaChi = address;
                diaDiem.MieuTa = description;
                diaDiem.ViDo = lat;
                diaDiem.KinhDo = lng;
                diaDiem.MaDichVu = type;
                diaDiem.NgayTao = DateTime.Now;
                diaDiem.MaTaiKhoan = 1;
                diaDiem.QuocGia = "Việt Nam";

                diaDiemService.Insert(diaDiem);

                Response.Redirect("MyPlaceFavorite.aspx");
            //}

           
        }
        private bool test()
        {
            return true;
        }
    }
}
